package com.wiener.web.managebeans;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.wiener.core.domain.Recibo;

public class ReciboDataModel extends ListDataModel<Recibo> implements SelectableDataModel<Recibo> {  

    public ReciboDataModel() {
    }

    public ReciboDataModel(List<Recibo> data) {
        super(data);
    }
    
    @Override
    public Recibo getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<Recibo> cars = (List<Recibo>) getWrappedData();
        
        for(Recibo car : cars) {
            if(car.getCodigo().equals(rowKey))
                return car;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(Recibo car) {
        return car.getCodigo(); 
    }
}